package com.demo.mq;

import com.demo.user.entity.User;
import com.demo.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class TaskMq {

	@Autowired
	private MsgProducer msgProducer;

	@Autowired
	private UserService userService;
	
	@Scheduled(cron="* * 1 * * *")
	public void test() throws InterruptedException {
		/*for(int i=1;i<=1000;i++){
			msgProducer.sendMsg(String.valueOf(i));
		}*/
		log.info("=======任务开始==========");
		User user = userService.selectByPrimaryKey(1L);
		Thread.sleep(10000);
		log.info("=======任务结束==========");

	}
}
